﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TitleDetailsViewModel.cs" company="saramgsilva">
//   Copyright (c) 2012 saramgsilva. All rights reserved.
// </copyright>
// <summary>
//   The title details view model.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Netflix.PortableClassLibrary.ViewModel
{
    using System.Windows.Input;

    using GalaSoft.MvvmLight;
    using GalaSoft.MvvmLight.Command;

    using Netflix.PortableClassLibrary.Model;
    using Netflix.PortableClassLibrary.Services;

    /// <summary>
    /// The title details view model.
    /// </summary>
    public class TitleDetailsViewModel : ViewModelBase
    {
        /// <summary>
        /// The navigation service.
        /// </summary>
        private INavigationService _navigationService;

        /// <summary>
        /// The service manager.
        /// </summary>
        private IServiceManager _serviceManager;

        /// <summary>
        /// The my title.
        /// </summary>
        private MyTitle _myTitle;

        /// <summary>
        /// Initializes a new instance of the <see cref="TitleDetailsViewModel" /> class.
        /// </summary>
        /// <param name="navigationService">The navigation service.</param>
        /// <param name="serviceManager">The service manager.</param>
        public TitleDetailsViewModel(INavigationService navigationService, IServiceManager serviceManager)
        {
            _navigationService = navigationService;
            _serviceManager = serviceManager;
            GoBackCommand = new RelayCommand(() => _navigationService.GoBack());
        }

        /// <summary>
        /// Gets or sets the can go back.
        /// </summary>
        public ICommand GoBackCommand { get; set; }

        /// <summary>
        /// Gets or sets the my title.
        /// </summary>
        public MyTitle Item
        {
            get
            {
                return _myTitle;
            }

            set
            {
                _myTitle = value;
                RaisePropertyChanged(() => Item);
            }
        }

        /// <summary>
        /// Gets the navigation service.
        /// </summary>
        /// <value>
        /// The navigation service.
        /// </value>
        public INavigationService NavigationService
        {
            get
            {
                return this._navigationService;
            }
        }

        /// <summary>
        /// Loads the data.
        /// </summary>
        /// <param name="myTitle">My title.</param>
        public void LoadData(MyTitle myTitle)
        {
            Item = myTitle;
        }
    }
}
